<template>
	<view style="height: 100vh;  position: relative;">
		<view @click="change(user.id)"
			style="width: 90%; margin: 0 auto; position: relative; padding: 30rpx 10rpx; display: flex;align-items: center;justify-content: space-around;">
			<image style="width: 150rpx;height: 150rpx; border-radius: 50%; position: relative; left:-10rpx;"
				:src="user.portrait?user.portrait:require('@/static/toux.png')" mode=""></image>
			<view style="font-size: 28rpx; position: relative; left:-40rpx;">
				{{user.username}}
			</view>
			<view style="font-size: 28rpx; color: rgb(171,175,178);position: relative; right:-10rpx;top:50rpx">
				个人信息
			</view>
		</view>

		<uni-list>
			<uni-list-item title="我的测试成绩" showArrow to='/pages/mine/mygrades' />
			<uni-list-item title="我的预约" showArrow to="/pages/appointment/myappointment" />
			<uni-list-item title="我的活动报名" showArrow to="/pages/activity/myactivity" />
			
		</uni-list>
		<view style="width: 100%; text-align: center; position: absolute; bottom: 50rpx;">
			<navigator url="/pages/login/login" open-type="redirect" hover-class="other-navigator-hover">

				<button type="primary" size="mini" style="margin: 10rpx;width: 30%; " @click="quit">退出登录</button>
			</navigator>
		</view>

	</view>
</template>

<script>
	export default {
		data() {
			return {
				user: {},
			}
		},
		onLoad() {



			this.user = uni.getStorageSync('user');
			this.loading();
		},
		onPullDownRefresh() {
			this.request({
				url: `/user/${this.user.id}`
			}).then(res => {
				if (res.code === '0') {
					setTimeout(function() {
						uni.stopPullDownRefresh();
						setTimeout(function() {
							uni.showToast({
								title: '加载成功'
							})
						}, 200);
					}, 800);
				}
				this.user = res.data;
			})
		},
		onShow() {
			this.loading();
		},
		methods: {
			loading() {
				this.request({
					url: `/user/${this.user.id}`
				}).then(res => {
					this.user = res.data;
					// console.log(this.user);
				});
			},
			change(userId) {
				uni.navigateTo({
					url: `/pages/mine/myperson?userId=${userId}`
				});

			},
			quit(){
				uni.removeStorageSync('user');
			},

		}
	}
</script>

<style>

</style>
